version: '3.9'
services:
  fitfriends.postgres:
    image: postgres:14.1-alpine
    container_name: fitfriends.postgres
    restart: always
    environment:
      POSTGRES_PORT: 5432
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    ports:
      - 5432:5432
    volumes:
      - ~/db/fitfriends.postgres:/var/lib/postgresql/data

    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${POSTGRES_USER} -d fitfriends']
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s
    networks:
      - fitfriends

  fitfriends.pgadmin:
    image: dpage/pgadmin4:8.0
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: 'keks@htmlacademy.local'
      PGADMIN_DEFAULT_PASSWORD: 'test'
      PGADMIN_CONFIG_SERVER_MODE: 'False'
    ports:
      - 8082:80
    networks:
      - fitfriends

  fitfriends.fakesmtp:
    image: gessnerfl/fake-smtp-server:2.0.0
    restart: 'always'
    hostname: fakesmtp
    ports:
      - 8025:8025
      - 1083:8080
    volumes:
      - ~/db/readme.notify.fakesmtp:/var/mail
    networks:
      - fitfriends

  fitfriends.backend:
    image: fit-friends-backend:latest
    restart: 'always'
    depends_on:
      - fitfriends.postgres
      - fitfriends.fakesmtp
    ports:
      - 4001:4000
    environment:
      - NODE_ENV=production
    env_file:
      - .env
    hostname: fitfriends
    networks:
      - fitfriends

  fitfriends.frontend:
    image: fit-friends-frontend:latest
    restart: 'always'
    depends_on:
      - fitfriends.postgres
      - fitfriends.fakesmtp
      - fitfriends.backend
    ports:
      - 80:80
    environment:
      - NODE_ENV=production
    env_file:
      - .fitfriends.frontend.env
    networks:
      - fitfriends
volumes:
  fitfriends.postgres:
networks:
  fitfriends:
    driver: bridge
